package com.iqiyi.pps.epg.core.model.sginal;

import com.iqiyi.pps.epg.api.model.web.sginal.TSginalBase;
import com.iqiyi.pps.epg.api.model.web.sginal.TSginalServer;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhang on 2017/4/26.
 */
@Entity
@Table(name = "sginal_base")
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class SginalBase {

    public static final int IS_DELETE = 1;
    public static final int IS_NOT_DELETE = 0;
    public static final int STATUS_INIT = 0;
    public static final int STATUS_START = 1;
    public static final int STATUS_STOP = 2;

    public static final String SGINAL_WARNNING_TYPE = "sginal_warnning";
    public static final String LOSS_SIZE_VALUE_TYPE = "loss_size";
    public static final long STATUS_TIME = 5 * 60 * 1000;

    public static final String[] SGINAL_TYPE_NAME = {"udp", "udi"};

    private Integer id;
    private String name;
    private String port;
    private String accessServerIp;
    private Integer status;
    private Integer isDelete;
    private String author;
    private Timestamp addTime;
    private Timestamp updateTime;

    public TSginalBase convertThriftModel(List<TSginalServer> sginalServers) {
        TSginalBase tSginalBase = new TSginalBase();
        tSginalBase.setId(this.id);
        tSginalBase.setName(this.name);
        tSginalBase.setPort(this.port);
        tSginalBase.setAccessServerIp(this.accessServerIp);
        tSginalBase.setStatus(this.status);
        tSginalBase.setAuthor(this.author);
        tSginalBase.setAddTime(this.addTime.toString());
        tSginalBase.setUpdateTime(this.updateTime.toString());
        tSginalBase.setSginalServers(sginalServers);
        return tSginalBase;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name="name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name="port")
    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    @Column(name="access_server_ip")
    public String getAccessServerIp() {
        return accessServerIp;
    }

    public void setAccessServerIp(String accessServerIp) {
        this.accessServerIp = accessServerIp;
    }

    @Column(name="status")
    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Column(name="is_delete")
    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    @Column(name="author")
    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    @Column(name="add_time")
    public Timestamp getAddTime() {
        return addTime;
    }

    public void setAddTime(Timestamp addTime) {
        this.addTime = addTime;
    }

    @Column(name="update_time", insertable = false, updatable = false)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }
}
